class Bet < ApplicationRecord
  enum state: [:pending, :win, :lose, :winned_half, :losed_half, :tie]

  belongs_to :user
  belongs_to :game
  belongs_to :team
  belongs_to :plan, optional: true

  def get_money
    if self.pending?
      "未结束"
    elsif self.win?
      if master_or_guest
        "#{money + money * game.master_index}"
      else
        "#{money + money * game.guest_index}"
      end
    elsif self.lose?
      "#{money}"
    else
      "0"
    end
  end
end
